package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.dto.BasisPositionResourceInfo;
import com.ruoyi.dto.BasisPositionResourceInfoUser;
import com.ruoyi.mapper.BaseResourceInfoMapper;
import com.ruoyi.service.IBaseResourceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.domain.BaseResourceInfo;
/**
 * 资源管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-23
 */
@Service
public class BaseResourceInfoServiceImpl implements IBaseResourceInfoService
{
    @Autowired
    private BaseResourceInfoMapper baseResourceInfoMapper;

    /**
     * 查询资源管理
     * 
     * @param id 资源管理主键
     * @return 资源管理
     */
    @Override
    public BaseResourceInfo selectBaseResourceInfoById(Long id)
    {
        return baseResourceInfoMapper.selectBaseResourceInfoById(id);
    }

    /**
     * 查询资源管理列表
     * 
     * @param baseResourceInfo 资源管理
     * @return 资源管理
     */
    @Override
    public List<BaseResourceInfo> selectBaseResourceInfoList(BaseResourceInfo baseResourceInfo)
    {
        return baseResourceInfoMapper.selectBaseResourceInfoList(baseResourceInfo);
    }

    /**
     * 新增资源管理
     * 
     * @param baseResourceInfo 资源管理
     * @return 结果
     */
    @Override
    public int insertBaseResourceInfo(BaseResourceInfo baseResourceInfo)
    {
        return baseResourceInfoMapper.insertBaseResourceInfo(baseResourceInfo);
    }

    /**
     * 修改资源管理
     * 
     * @param baseResourceInfo 资源管理
     * @return 结果
     */
    @Override
    public int updateBaseResourceInfo(BaseResourceInfo baseResourceInfo)
    {
        return baseResourceInfoMapper.updateBaseResourceInfo(baseResourceInfo);
    }

    /**
     * 批量删除资源管理
     * 
     * @param ids 需要删除的资源管理主键
     * @return 结果
     */
    @Override
    public int deleteBaseResourceInfoByIds(Long[] ids)
    {
        return baseResourceInfoMapper.deleteBaseResourceInfoByIds(ids);
    }

    /**
     * 删除资源管理信息
     * 
     * @param id 资源管理主键
     * @return 结果
     */
    @Override
    public int deleteBaseResourceInfoById(Long id)
    {
        return baseResourceInfoMapper.deleteBaseResourceInfoById(id);
    }

    @Override
    public boolean addBasisPositionResourceInfo(BasisPositionResourceInfo basisPositionResourceInfo) {
        String[] split = basisPositionResourceInfo.getResourceIds().split(",");
        for (String resourceId : split) {
            basisPositionResourceInfo.setResourceId(Integer.valueOf(resourceId));
            boolean b = baseResourceInfoMapper.addBasisPositionResourceInfo(basisPositionResourceInfo);
            if (!b) return false;
        }
        return true;
    }

    @Override
    public List<BaseResourceInfo> findByLoadingIdAndPositionIdFromResource(String loadingId, Integer positionId) {
        return baseResourceInfoMapper.findByLoadingIdAndPositionIdFromResource(loadingId,positionId);
    }

    @Override
    public List<BaseResourceInfo> findByLoadingIdFromResource(String loadingId) {
        return baseResourceInfoMapper.findByLoadingIdFromResource(loadingId);
    }

    @Override
    public boolean delBasisPositionResourceInfo(String loadingId, Integer positionId, Integer resourceId) {
        return baseResourceInfoMapper.delBasisPositionResourceInfo(loadingId, positionId, resourceId);
    }

    @Override
    public boolean delBasisPositionResourceInfoAll(String loadingId, Integer positionId) {
        return baseResourceInfoMapper.delBasisPositionResourceInfodel(loadingId, positionId);
    }

    @Override
    public BaseResourceInfo findByResourceIdAndLoading(Integer resourceId, String loadingId) {
        return baseResourceInfoMapper.findByResourceIdAndLoading(resourceId, loadingId);
    }


}
